package com.liujun.spring4.demo.aop.iocset.annotation.autowired.serviceFunction;

import com.liujun.spring4.demo.aop.iocset.annotation.autowired.dao.LogDao;
import com.liujun.spring4.demo.aop.iocset.annotation.autowired.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * @author liujun
 * @version 1.0
 * @date 2018-08-19 14:32:00
 */
@Service
public class LogonServiceImpl implements LogonService {

  private LogDao logDao;

  private UserDao userDao;

  @Override
  public boolean userLogin(String userName, String passwd) {

    System.out.println("invoke userDao");
    this.userDao.login(userName, passwd);
    this.logDao.addLog(userName);
    System.out.println("invoke over");

    return true;
  }

  @Autowired
  @Qualifier("logDaoOtherImpl")
  public void setLogDao(LogDao logDao) {
    this.logDao = logDao;
  }

  @Autowired
  public void setUserDao(UserDao userDao) {
    this.userDao = userDao;
  }
}
